package com.extweb4j.core.model;

import java.util.List;

/**
 * @author ZhaoWeinan
 * @date 2019/1/7
 * @description
 */
public class ExtFeedback extends CoreModel<ExtFeedback> {

    private static final long serialVersionUID = 1L;

    public static ExtFeedback dao = new ExtFeedback();

    private static final String SELECT_SQL = "SELECT RunId, PrcsId, UserId, Content, AttachmentId, EditTime ";

    private static final String FROM_SQL = " FROM Flow_Run_Feedback ";

    private static final String WHERE_SQL = " WHERE 1=1 ";

    public boolean isExist(String str) {
        // TODO Auto-generated method stub
        return super.findBy("Id = ?", str) == null;
    }

    public List<ExtFeedback> getFeedbackList(String runId) {
        // TODO Auto-generated method stub
        StringBuffer form = new StringBuffer();
        form.append(SELECT_SQL);
        form.append(FROM_SQL);
        form.append(WHERE_SQL);
        form.append(" AND RunId=");
        form.append(runId);
        form.append(" ORDER BY PrcsId ");
        return super.find(form.toString());
    }

    /**
     * 根据id 获取新闻实体类
     *
     * @return
     * @Param id
     */
    public ExtDepartment findDepartmentById(String id) {
        // TODO Auto-generated method stub
        return ExtDepartment.dao.findFirst("SELECT * FROM  Department where DeptId=?", id);
    }

    public ExtUser getUserNameByUserId(String id) {
        return ExtUser.dao.findFirst("SELECT * FROM  Department where id=?", id);
    }

    public String getId() {
        return this.getStr("id");
    }
}
